1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gdk.AppLaunchContext;
26 
27 private import gdk.Display;
28 private import gdk.c.functions;
29 public  import gdk.c.types;
30 private import gio.AppLaunchContext : DGioAppLaunchContext = AppLaunchContext;
31 private import gio.IconIF;
32 private import glib.Str;
33 private import gobject.ObjectG;
34 
35 
36 /**
37  * `GdkAppLaunchContext` handles launching an application in a graphical context.
38  * 
39  * It is an implementation of `GAppLaunchContext` that provides startup
40  * notification and allows to launch applications on a specific workspace.
41  * 
42  * ## Launching an application
43  * 
44  * ```c
45  * GdkAppLaunchContext *context;
46  * 
47  * context = gdk_display_get_app_launch_context (display);
48  * 
49  * gdk_app_launch_context_set_timestamp (gdk_event_get_time (event));
50  * 
51  * if (!g_app_info_launch_default_for_uri ("http://www.gtk.org", context, &error))
52  * g_warning ("Launching failed: %s\n", error->message);
53  * 
54  * g_object_unref (context);
55  * ```
56  */
57 public class AppLaunchContext : DGioAppLaunchContext
58 {
59 	/** the main Gtk struct */
60 	protected GdkAppLaunchContext* gdkAppLaunchContext;
61 
62 	/** Get the main Gtk struct */
63 	public GdkAppLaunchContext* getGdkAppLaunchContextStruct(bool transferOwnership = false)
64 	{
65 		if (transferOwnership)
66 			ownedRef = false;
67 		return gdkAppLaunchContext;
68 	}
69 
70 	/** the main Gtk struct as a void* */
71 	protected override void* getStruct()
72 	{
73 		return cast(void*)gdkAppLaunchContext;
74 	}
75 
76 	/**
77 	 * Sets our main struct and passes it to the parent class.
78 	 */
79 	public this (GdkAppLaunchContext* gdkAppLaunchContext, bool ownedRef = false)
80 	{
81 		this.gdkAppLaunchContext = gdkAppLaunchContext;
82 		super(cast(GAppLaunchContext*)gdkAppLaunchContext, ownedRef);
83 	}
84 
85 
86 	/** */
87 	public static GType getType()
88 	{
89 		return gdk_app_launch_context_get_type();
90 	}
91 
92 	/**
93 	 * Gets the `GdkDisplay` that @context is for.
94 	 *
95 	 * Returns: the display of @context
96 	 */
97 	public Display getDisplay()
98 	{
99 		auto __p = gdk_app_launch_context_get_display(gdkAppLaunchContext);
100 
101 		if(__p is null)
102 		{
103 			return null;
104 		}
105 
106 		return ObjectG.getDObject!(Display)(cast(GdkDisplay*) __p);
107 	}
108 
109 	/**
110 	 * Sets the workspace on which applications will be launched.
111 	 *
112 	 * This only works when running under a window manager that
113 	 * supports multiple workspaces, as described in the
114 	 * [Extended Window Manager Hints](http://www.freedesktop.org/Standards/wm-spec).
115 	 * Specifically this sets the `_NET_WM_DESKTOP` property described
116 	 * in that spec.
117 	 *
118 	 * This only works when using the X11 backend.
119 	 *
120 	 * When the workspace is not specified or @desktop is set to -1,
121 	 * it is up to the window manager to pick one, typically it will
122 	 * be the current workspace.
123 	 *
124 	 * Params:
125 	 *     desktop = the number of a workspace, or -1
126 	 */
127 	public void setDesktop(int desktop)
128 	{
129 		gdk_app_launch_context_set_desktop(gdkAppLaunchContext, desktop);
130 	}
131 
132 	/**
133 	 * Sets the icon for applications that are launched with this
134 	 * context.
135 	 *
136 	 * Window Managers can use this information when displaying startup
137 	 * notification.
138 	 *
139 	 * See also [method@Gdk.AppLaunchContext.set_icon_name].
140 	 *
141 	 * Params:
142 	 *     icon = a `GIcon`
143 	 */
144 	public void setIcon(IconIF icon)
145 	{
146 		gdk_app_launch_context_set_icon(gdkAppLaunchContext, (icon is null) ? null : icon.getIconStruct());
147 	}
148 
149 	/**
150 	 * Sets the icon for applications that are launched with this context.
151 	 *
152 	 * The @icon_name will be interpreted in the same way as the Icon field
153 	 * in desktop files. See also [method@Gdk.AppLaunchContext.set_icon].
154 	 *
155 	 * If both @icon and @icon_name are set, the @icon_name takes priority.
156 	 * If neither @icon or @icon_name is set, the icon is taken from either
157 	 * the file that is passed to launched application or from the `GAppInfo`
158 	 * for the launched application itself.
159 	 *
160 	 * Params:
161 	 *     iconName = an icon name
162 	 */
163 	public void setIconName(string iconName)
164 	{
165 		gdk_app_launch_context_set_icon_name(gdkAppLaunchContext, Str.toStringz(iconName));
166 	}
167 
168 	/**
169 	 * Sets the timestamp of @context.
170 	 *
171 	 * The timestamp should ideally be taken from the event that
172 	 * triggered the launch.
173 	 *
174 	 * Window managers can use this information to avoid moving the
175 	 * focus to the newly launched application when the user is busy
176 	 * typing in another window. This is also known as 'focus stealing
177 	 * prevention'.
178 	 *
179 	 * Params:
180 	 *     timestamp = a timestamp
181 	 */
182 	public void setTimestamp(uint timestamp)
183 	{
184 		gdk_app_launch_context_set_timestamp(gdkAppLaunchContext, timestamp);
185 	}
186 }